<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>注册</title>
	<link href="<?php echo G_STATIC_URL; ?>/css/default/index.css" rel="stylesheet" />
	<link href="<?php echo G_STATIC_URL; ?>/css/default/global.css?v=1" rel="stylesheet" />



	<link rel="stylesheet" href="<?php echo G_STATIC_URL; ?>/js/layer/layer.css" />
	<script src="<?php echo G_STATIC_URL; ?>/js/layer/layer.js"></script>
	<script src="<?php echo G_STATIC_URL; ?>/js/jquery-2.1.1.min.js"></script>


	<link rel="stylesheet" href="<?php echo G_STATIC_URL; ?>/css/bootstrap.min.css">
	<link rel="stylesheet" href="<?php echo G_STATIC_URL; ?>/css/font-awesome.min.css">
	<link rel="stylesheet" href="<?php echo G_STATIC_URL; ?>/css/main.css">
	<link rel="stylesheet" href="<?php echo G_STATIC_URL; ?>/css/animate.css">
	<link rel="stylesheet" href="<?php echo G_STATIC_URL; ?>/css/responsive.css">


</head>
<body style="background-color: #f2f6fa;">
<header>
	<div class="container">
		<div class="row">
			<div class="col-md-3 col-xs-6 col-sm-3">
				<a href="/?/explore/index/" class="logo">
					<img src="<?php echo G_STATIC_URL; ?>/css/images/logo.png" alt="">
				</a>
			</div>


		</div>
	</div>
</header>

    <br/>
	<br/>
	<br/>
	<div class="content">
		<div class="register_content">
			<div class="reg_title">
				<div class="title">用户注册</div>
				<div class="login_link">
					<span class="pt1">已有账户？</span>
					<a href=""><span class="pt2">登录</span></a>
				</div>
			</div>
			<div class="register-if">
				<div class="input_main">
					<div class="input_phone">
						<span class="left_it"><img src="<?php echo G_STATIC_URL; ?>/common/mphoneicon.png" alt="">手   机   号：  </span>
						<span class="input_tt"><input type="text" name="phone" id="rg_phone" placeholder="请输入手机号"></span>
					</div>

					<div class="input_phone">
						<span class="left_it"><img src="<?php echo G_STATIC_URL; ?>/common/mphoneicon.png" alt="">企业名字：</span>
						<span class="input_tt"><input type="text" name="phone" id="name" placeholder="请输入企业名字"></span>
					</div>

					<div class="input_phone">
						<span class="left_it"><img src="<?php echo G_STATIC_URL; ?>/common/codeicon.png" alt="">验 证 码：   </span>
						<span class="input_cd"><input type="text" id="rg_code" placeholder="输入验证码"></span>
						<span class="bt_cd" onclick="send_code();">获取验证码</span>
					</div>

					<div class="password fill_main input_phone">
						<span class="left_it"><img src="<?php echo G_STATIC_URL; ?>/common/paswdicon.png" alt="">密&nbsp;&nbsp;&nbsp;&nbsp;码：</span>
						<span class="input_tt"><input type="text" id="password"  placeholder="请输入你的密码"></span>
					</div>

				</div>
				<div class="login_btn">
					<span class="lgbtn" id="register_btn">下一步</span>
				</div>
				<div class="pt_tt">
					<!--<span class="pt1">注册代表你已同意</span>-->
					<!--<a href=""><span class="pt2">《用户协议》</span></a>-->
					<!--<span class="pt1">和</span>-->
					<!--<a href=""><span class="pt2">《隐私条款》</span></a>-->
				</div>
			</div>
		</div>

	</div>


<script>
	$(function(){
		register();
		$(".id_option").click(function(){
			$(".sec").removeClass('active');
			$(this).find(".sec").addClass('active');
			$("input[name=identity]").attr('checked',false);
			$(this).find("input[name=identity]").prop("checked", "checked");
		});
	});
	function register(){
		$("#register_btn").click(function(){
			var phone=$("#rg_phone").val();
			var code=$("#rg_code").val();
			var name = $('#name').val();
			var password = $('#password').val();
			if(phone.length==0){
				showMsg('请输入手机号');
				return;
			}
			if(code.length==0){
				showMsg('请输入验证码');
				return;
			}
			if(name.length == 0){
				showMsg('请输入企业名字');
				return;
			}
			if(password.length == 0){
				showMsg('请输入密码');
				return;
			}

			var url = "/?/account/ajax/reg_user/"
			$.post(url,{"phone":phone,"code":code,"name":name,"password":password},function (result) {

				if(result.errno == 1){
					window.location.href="/?/account/company_data/";
				}else{
					showMsg(result.err);
				}
			},'json');



		});
	}
				/**
	 * 倒计时
	 */
	var wait = 60;
	var code_state = "IDLE";
	function count_down(){
	    if(wait <= 0){
	        $(".bt_cd").removeClass("active")
	        $(".bt_cd").attr("onclick", "send_code()");
	        $(".bt_cd").html("获取验证码");
	        wait = 60;
	        code_state = "IDLE";
	    } else {
	        $(".bt_cd").addClass("active")
	        $(".bt_cd").attr("onclick", "");
	        $(".bt_cd").html( "剩余" + wait + "秒");
	        wait--;
	        setTimeout(count_down, 1000);
	    }
	}

	/**
	 * 发送短信验证码
	 */
	function send_code(){
	    if (code_state != "IDLE"){
	        return;
	    }
	    var tel = $.trim($("input[name='phone']").val());
	    var reg = /^1[3|4|5|7|8][0-9]\d{8}$/;

	    if(false == reg.test(tel)){
	        showMsg('请输入正确的手机号');
	        return ;
	    }
	    code_state = "SENDING";
	    count_down();


	}
		/**
	 * 显示消息
	 */
	function showMsg(msg,time) {
	    layer.open({
	        content: msg ,
	        time: time ? time : 2 //3秒后自动关闭
	    });
	}		
	</script>
</body>
</html>